package org.moonlight.jvm.instructions.stack.dup;

import org.moonlight.jvm.instructions.base.NoOperandsInstruction;
import org.moonlight.jvm.rtda.exclusive.Frame;
import org.moonlight.jvm.rtda.exclusive.OperandStack;
import org.moonlight.jvm.rtda.exclusive.Slot;

/**
 * DUP: dup指令复制栈顶的单个变量
 *
 * @author Moonlight
 * @createTime 2023/8/16 17:12
 **/
public class Dup extends NoOperandsInstruction {
    @Override
    public void execute(Frame frame) {
        OperandStack operandStack = frame.getOperandStack();
        Slot slot = operandStack.popSlot();
        operandStack.pushSlot(slot);
        operandStack.pushSlot(slot);
    }
}
